package com.example.back.dao;

import com.example.back.bean.UserSign;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

@Mapper
public interface UserSignDao {

    @Select("select * from user_sign_log where userId=#{userId} and type=0 order by signTime desc limit 0,1;")
    UserSign getOne(long userId);

    @Insert("insert into user_sign_log(userId,signTime,reward,number,ads,type)values(#{userId},#{signTime},#{reward},#{number},#{ads},#{type})")
    void insert(long userId, Date signTime,String reward,int number,int ads,int type);

    @Update("update user_sign_log set number=-1 where type=0")
    void update();

    @Select("select * from user_sign_log where userId=#{userId} and type=1 order by signTime desc limit 0,1;")
    UserSign getType1(long userId);
}
